package models;

import javax.persistence.Entity;
import javax.persistence.OneToOne;

import play.data.validation.Required;
import play.db.jpa.Model;

@Entity
public class ShoppingCartLine extends Model {
	
	@Required
	public int quantity;
	
	@Required
	@OneToOne
	public Product product;
		
	public ShoppingCartLine(Product product) {
		this.product = product;
		this.quantity = 1;
		create();
	}
	
	public int getCalories() {
		return this.quantity * this.product.getCalories();
	}
	
	public double getPrice() {
		return this.quantity * this.product.getPrice();
	}
	
}
